package controllers

import (
	"fmt"
	"myblog/utils"

	beego "github.com/beego/beego/v2/server/web"
)

type AdminDelController struct {
	beego.Controller
}

func (this *AdminDelController) Get() {
	delfile := this.Ctx.Input.Param(":splat")
	err := utils.RemoveFile("/" + delfile)
	if err != nil {
		fmt.Println("remove file error:", err)
	}
	postdir, _ := beego.AppConfig.String("postdir")
	postdir = utils.GetCurrentPath() + postdir
	files, _ := utils.ListDir(postdir)
	this.Data["Files"] = files
	this.TplName = "model/table.tpl"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["IndexHead"] = "model/head.tpl"
	this.LayoutSections["IndexNavbar"] = "model/navbar.tpl"
	this.LayoutSections["IndexNav"] = "model/nav.tpl"
	this.LayoutSections["IndexFoot"] = "model/foot.tpl"
	this.Layout = "index.tpl"

}
